package game.physics;

import common.Coordinate;
import common.Rectangle;
import common.Vector;

public final class SimulationBody {
	{
		LastLocation = new Coordinate();
		Location = new Coordinate();
		HitBox = new Rectangle();
		Velocity = new Vector();
	}
	public final Coordinate LastLocation;
	public final Coordinate Location;
	public final Rectangle HitBox;
	public final Vector Velocity;
	private float _Xf;
	private float _Yf;
	public void setLocation(Coordinate location) {
		location.copyTo(LastLocation);
		location.copyTo(Location);
	}
	public void move(Vector velocity) {
		Location.copyTo(LastLocation);
		int dx = (int)velocity.X;
		int dy = (int)velocity.Y;
		_Xf = _Xf + (velocity.X - dx);
		_Yf = _Yf + (velocity.Y - dy);
		Location.translate(dx + (int)_Xf, dy + (int)_Yf);
		// save the fraction
		_Xf -= (int)_Xf; 
		_Yf -= (int)_Yf;
	}
}
